<!doctype html>
<html>
  <head>
    <title>Test ClearRect works properly if called during the first frame.</title>
  </head>
  <body>
  <canvas id="c" width=100 height=100></canvas>
  <script>

var c2 = document.getElementById("c");
var offscreen_canvas = c2.transferControlToOffscreen();
var ctx_o = offscreen_canvas.getContext('2d');

// Since it checks if content retaining |mode_| changes from frame to frame,
// multiple calls to rAF are used to assure the craetion of new frame.
ctx_o.fillRect(5, 5, 50, 50);
ctx_o.clearRect(0, 0, 800, 1000);
window.requestAnimationFrame( dt=> {
  ctx_o.fillRect(50, 50, 50, 50);
  ctx_o.clearRect(50, 50, 50, 40);
  window.requestAnimationFrame(dt => {
    ctx_o.fillRect(0, 0, 15, 15);
    window.requestAnimationFrame(dt => {
      testRunner.notifyDone();
    });
  });
});

if (window.testRunner) {
  testRunner.waitUntilDone();
}

</script>
</body>
</html>
